/**
 * 指定值范围内，所有奇数的斐波那契数字之和
 * # Arguments
 * * `amount` - 上界（不包含）
 * # Returns
 * 总和
 * # Examples
```
let s = solution5::fibnacci::odd_fibnacci_sum(20);
assert_eq!(s, 23);
```
 */
pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    let mut fibnacci_values = vec![0u32, 1u32];
    let mut ret = 1u32;
    let mut pos = 2 as usize;
    loop {
        let new_value = fibnacci_values[pos - 1] + fibnacci_values[pos - 2];
        if new_value >= threshold {
            break;
        }
        fibnacci_values.push(new_value);
        if new_value % 2 == 1 {
            ret += new_value;
        }
        pos += 1;
    }
    ret
}
